package com.baidu.mapapi;

import android.graphics.Point;
import android.os.Message;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnKeyListener;

public class MapController
  implements View.OnKeyListener
{
  private MapView a = null;

  MapController(MapView paramMapView)
  {
    this.a = paramMapView;
    paramMapView.b.setOnKeyListener(this);
  }

  public void animateTo(GeoPoint paramGeoPoint)
  {
    this.a.a(paramGeoPoint, null, null);
  }

  public void animateTo(GeoPoint paramGeoPoint, Message paramMessage)
  {
    this.a.a(paramGeoPoint, paramMessage, null);
  }

  public void animateTo(GeoPoint paramGeoPoint, Runnable paramRunnable)
  {
    this.a.a(paramGeoPoint, null, paramRunnable);
  }

  public boolean onKey(View paramView, int paramInt, KeyEvent paramKeyEvent)
  {
    int i;
    if (this.a.b == paramView)
      if (paramKeyEvent.getAction() != 0)
        i = 0;
    while (true)
    {
      while (true)
      {
        return i;
        switch (paramInt)
        {
        default:
          i = 0;
        case 21:
        case 22:
        case 19:
        case 20:
        }
      }
      scrollBy(-50, 0);
      while (true)
      {
        while (true)
        {
          while (true)
          {
            while (true)
              i = 1;
            scrollBy(50, 0);
          }
          scrollBy(0, -50);
        }
        scrollBy(0, 50);
      }
      i = 0;
    }
  }

  public void scrollBy(int paramInt1, int paramInt2)
  {
    if ((paramInt1 == 0) && (paramInt2 == 0));
    while (true)
    {
      return;
      this.a.b(paramInt1, paramInt2);
    }
  }

  public void setCenter(GeoPoint paramGeoPoint)
  {
    this.a.a(paramGeoPoint);
  }

  public int setZoom(int paramInt)
  {
    this.a.a(paramInt);
    return this.a.getZoomLevel();
  }

  public void stopAnimation(boolean paramBoolean)
  {
    this.a.a(paramBoolean);
  }

  public void stopPanning()
  {
    setCenter(this.a.getMapCenter());
  }

  public boolean zoomIn()
  {
    return this.a.d();
  }

  public boolean zoomInFixing(int paramInt1, int paramInt2)
  {
    GeoPoint localGeoPoint = this.a.getProjection().fromPixels(paramInt1, paramInt2);
    boolean bool = zoomIn();
    if (bool)
    {
      Point localPoint = new Point();
      this.a.getProjection().toPixels(localGeoPoint, localPoint);
      scrollBy(localPoint.x - paramInt1, localPoint.y - paramInt2);
    }
    return bool;
  }

  public boolean zoomOut()
  {
    return this.a.e();
  }

  public boolean zoomOutFixing(int paramInt1, int paramInt2)
  {
    GeoPoint localGeoPoint = this.a.getProjection().fromPixels(paramInt1, paramInt2);
    boolean bool = zoomOut();
    if (bool)
    {
      Point localPoint = new Point();
      this.a.getProjection().toPixels(localGeoPoint, localPoint);
      scrollBy(localPoint.x - paramInt1, localPoint.y - paramInt2);
    }
    return bool;
  }

  public void zoomToSpan(int paramInt1, int paramInt2)
  {
    this.a.a(paramInt1, paramInt2);
  }
}